/*
 * @(#) $Header$
 *
 * Copyright (C) 2010  Daniel Léonard
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */

package ca.forklabs.crypto.md;

import java.security.spec.AlgorithmParameterSpec;
import java.text.MessageFormat;
import java.util.ResourceBundle;

/**
 * Class {@code Resources} is the default bundle for the resources used by
 * classes in the {@link ca.forklabs.crypto.md} package.
 *
 * @author   <a href="mailto:forklabs at gmail.com?subject=ca.forklabs.crypto.md.Resources">Daniel Léonard</a>
 * @version $Revision$
 */
@SuppressWarnings("nls")
class Resources {

//---------------------------
// Class variables
//---------------------------

   /** The key of the error message when a parameter is not positive. */
   public static final String PARAMETER_NOT_POSITIVE = "parameter.not.positive";
   /** The key of the error message when a {@link AlgorithmParameterSpec} is not of the right class. */
   public static final String BAD_SPEC_CLASS = "bad.spec.class";

   /** The key of the error message when an incorrect hash length has been chosen in HAVAL. */
   public static final String HAVAL_BAD_HASH_LEN = "haval.bad.hash.len";
   /** The key of the error message when an number of passes has been chosen in HAVAL. */
   public static final String HAVAL_BAD_PASSES = "haval.bad.passes";

   /** The key of the error message when an incorrect hash length has been chosen in SNEFRU. */
   public static final String SNEFRU_BAD_HASH_LEN = "snefru.bad.hash.len";
   /** The key of the error message when an number of passes has been chosen in SNEFRU. */
   public static final String SNEFRU_BAD_PASSES = "snefru.bad.passes";


//---------------------------
// Constructor
//---------------------------

   /**
    * Let no one instanciate this class.
    */
   private Resources() {
   // nothing
      }


//---------------------------
// Class method
//---------------------------

   /**
    * Gets the resource bundle itself.
    * @return   the resource bundle.
    */
   public static ResourceBundle getResourceBundle() {
      String name = Resources.class.getName();
      ResourceBundle bundle = ResourceBundle.getBundle(name);
      return bundle;
      }

   /**
    * Gets and formats the specified localized string from the menu resource
    * bundle.
    * @param   key   the key.
    * @param   arguments   the arguments to format the string.
    * @return   the value.
    */
   public static String getLocalizedString(String key, Object... arguments) {
      ResourceBundle bundle = Resources.getResourceBundle();
      String pattern = bundle.getString(key);
      String message = MessageFormat.format(pattern, arguments);
      return message;
      }

   }

